// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import config from "../config/config";
import func from "../config/func";
import AudioManage from "../manage/AudioManage";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Ranking extends cc.Component {

    @property(cc.Node)
    m_bg: cc.Node = null;
    @property(cc.Node)
    m_cont: cc.Node = null;

    init() {
        config.openPopup = false;
        func.setNodeAni(this.m_bg, () => {
            this.m_cont.active = true;
        });
        if (config.gameType == "wx") {
            window["wx"].postMessage({
                key: "score",
                money: config.checkPoint
            })
        }
    }

    close() {
        AudioManage.audioManage.playEffectMusic(config.soundPath.click);
        this.m_cont.active = false;
        func.goReduceOut(this.m_bg, () => {
            this.node.active = false;
        })
    }
}
